Skip to content

Fix cached runtime embedding across feature builds - #551

Merged
ludfjig merged 1 commit into
mainfrom
fix_build_bug
Sep 21, 2026
Merged

ludfjig merged 1 commit into
mainfrom
fix_build_bug

Conversation

@ludfjig

@ludfjig ludfjig commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Copy the built runtime into OUT_DIR and use that copy for embedding and build metadata.

Native and Pulley builds share one runtime output path. Pulley can overwrite that file while Cargo retains the native build script’s cached output. A later native library compilation then embeds Pulley.

Each configuration’s OUT_DIR copy preserves its runtime. The nested Cargo target directory remains shared to reuse compiled dependencies.

Original Reproduction

cargo build --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm --features pulley
cargo build --release -p hyperlight-wasm

Before this fix, the third build can embed Pulley despite requesting native.

Why File Tracking Is Insufficient

Adding cargo::rerun-if-changed for the shared binary can miss changes. Nested Cargo can restore a cached binary whose modification time predates the native build script’s last run.

With that directive present, first warm both runtime caches:

cargo build --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm --features pulley

Then clear only the outer package’s artifacts and reproduce:

cargo clean --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm --features pulley
touch src/hyperlight_wasm/src/lib.rs
cargo build --release -p hyperlight-wasm

The final build recompiles the native library but reuses its cached build-script output. It embeds the shared Pulley binary. touch changes only the source timestamp.

Fixes #547

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig
ludfjig merged commit 6b14df7 into main Sep 21, 2026
39 of 40 checks passed
@ludfjig
ludfjig deleted the fix_build_bug branch September 21, 2026 19:51
jprendes pushed a commit to hyperlight-dev/hyperlight-js that referenced this pull request Sep 21, 2026
Copy the selected runtime into `OUT_DIR` and use that copy for
embedding.

Default and `trace_guest` builds share one runtime output path. A
`trace_guest` build can overwrite that file while Cargo retains the
default build script's cached output. A later default library
compilation then embeds the trace-enabled runtime.

Each configuration's `OUT_DIR` copy preserves its runtime. The nested
Cargo target directory remains shared to reuse compiled dependencies.
Custom runtimes supplied through `HYPERLIGHT_JS_RUNTIME_PATH` retain
their existing environment and source-file tracking.

### Original Reproduction

```sh
cargo build --release -p hyperlight-js
cargo build --release -p hyperlight-js --features trace_guest
cargo build --release -p hyperlight-js
```

Before this fix, the third build embedded the trace-enabled runtime
despite requesting default

Uses the same approach as in in
hyperlight-dev/hyperlight-wasm#551.

Fixes #296

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy the generated guest runtime into OUT_DIR

2 participants